from pymilvus import connections,db

# conn = connections.connect(host="49.234.21.142",port="19530")

#创建数据库
# db.create_database("my_database")

#使用数据库
# db.using_database("my_database")
#列出数据库
# dbs = db.list_database()
# print(dbs)

#["default","my_database"]
#删除数据库
# db.drop_database("my_database")


#案例二
# from pymilvus import FieldSchema,DataType

#字段定义示例
# fields = [
#     FieldSchema(name="id",dtype=DataType.INT64,is_primary=True),
#     FieldSchema(name="vector",dtype=DataType.FLOAT_VECTOR,dim=128),
#     FieldSchema(name="category",dtype=DataType.VARCHAR,max_length=50),
# ]

#案例三
from pymilvus import connections
from pymilvus import FieldSchema,DataType
from pymilvus import CollectionSchema,Collection

conn = connections.connect(host="49.234.21.142",port="19530")

#步骤1:字段定义
fields = [
    FieldSchema(name="id",dtype=DataType.INT64,is_primary=True),
    FieldSchema(name="vector",dtype=DataType.FLOAT_VECTOR,dim=128),
    FieldSchema(name="tag",dtype=DataType.VARCHAR,max_length=50),
]

#步骤2：创建Schema
schema = CollectionSchema(fields,description="示例集合",enable_dynamic_field=True)

#步骤3:实例化Collection
collection = Collection(
    name="demo_collection",
    schema=schema,
    shards_num=2
)